<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2022-10-06
 * Time: 21:50
 */

namespace App\controller\bbs;

use App\server\dtk\DtkClient;
use App\server\work\FactoryWork;
use GuzzleHttp\Client;
class Bi
{
    public function index(Request $request)
    {
        $app = FactoryWork::app(3);
        $messenger = $app->messenger;
        $uid='13385200280';
        $message = new \EasyWeChat\Kernel\Messages\TextCard([
            'title' => '有用户试图登录',
            'description' => '本数据为自动测试数据',
            'url' => 'https://work.weixin.qq.com/',
            'btntxt'=>'点击查看'
        ]);
        $r=$messenger->message($message)->toUser($uid)->send();
        $callbackUrl = 'https://start.wyx2013.cn/work/index';
        $redirect = $app->oauth->redirect($callbackUrl);
        $targetUrl = $redirect->getTargetUrl();
        //return response($targetUrl);
        //var_export($r);
        return json($r);
    }

    public function test()
    {
        $client=new Client();
        $response = $client->get('https://guzzle-cn.readthedocs.io/zh_CN/latest/quickstart.html');
        return response($response->getBody());
    }

    public function error()
    {
        $data=[
            'version'=>'v2.1.0',
            'type'=>0,
            'pageId'=>30,
            'keyWords'=>'双丁'
        ];

        $d=new DtkClient('https://openapi.dataoke.com/api/tb-service/get-tb-service',$data);
        return response($d->getBody());
    }
}